package com.zzx.magic.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zzx.magic.entity.BpInterested;
import com.zzx.magic.entity.BusinessPlan;
import com.zzx.magic.mapper.BpInterestedMapper;
import com.zzx.magic.mapper.BusinessPlanMapper;
import com.zzx.magic.service.IBpInterestedService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * <p>
 * 项目兴趣表 服务实现类
 * </p>
 *
 * @author ZhangXx
 * @since 2024-06-12
 */
@Service
public class BpInterestedServiceImpl extends ServiceImpl<BpInterestedMapper, BpInterested> implements IBpInterestedService {

    @Autowired
    BpInterestedMapper bpInterestedMapper;

    @Autowired
    BusinessPlanMapper businessPlanMapper;


    @Override
    public void insert(BpInterested bpInterested) {
        bpInterestedMapper.insert(bpInterested);
    }

    @Override
    public List<BusinessPlan> interestedList(String id) {
        List<BpInterested> list = bpInterestedMapper.selectList(new QueryWrapper<BpInterested>().eq("user_id", id));
        List<Integer> integerList = Collections.emptyList();
        for(BpInterested bpInterested: list) {
            integerList.add(bpInterested.getBpId());
        }
        return businessPlanMapper.selectBatchIds(integerList);
    }
}
